package com.cat.greedyAlgorithm;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/eliminate-maximum-number-of-monsters/
 * @create 2025/10/9 15:40
 * @since JDK17
 */

public class Solution66 {
    public int eliminateMaximum(int[] dist, int[] speed) {
        int n = dist.length, ans = 0;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = (dist[i] + speed[i] - 1) / speed[i];
        }
        // 按照达到的时间来排序
        Arrays.sort(arr);
        for (int i = 0; i < n; i++) {   //
            if (i + 1 > arr[i]) {   //
                return i;
            }
        }

        return n;
    }
}
